#include "sln.h"

int slnBruteForce(std::string s)
{
    ptrdiff_t sLen = s.length();

    int result = 0;
    // loop invariant:
    // [0, aPos) has tried
    // result is the count in tried range
    for (ptrdiff_t aPos = 0; aPos < sLen; ++aPos) {
        // loop invariant:
        // [aPos + 1, bPos) has tried
        for (ptrdiff_t bPos = aPos + 1; bPos < sLen; ++bPos) {
            // loop invariant:
            // [bPos + 1, cPos) has tried
            for (ptrdiff_t cPos = bPos + 1; cPos < sLen; ++cPos) {
                // loop invariant:
                // [cPos + 1, dPos) has tried
                for (ptrdiff_t dPos = cPos + 1; dPos < sLen; ++dPos) {
                    char aValue = s[aPos];
                    char bValue = s[bPos];
                    char cValue = s[cPos];
                    char dValue = s[dPos];
                    if (aValue == dValue && bValue == cValue) {
                        ++result;
                        result = result % (1000000000 + 7);
                    }
                }
                // post condition:
                // [cPos + 1, sLen) has tried
            }
            // post condition: [bPos + 1, sLen) has tried
        }
        // post condition:
        // [aPos + 1, sLen) has tried
    }
    // post condition:
    // [0, sLen) has tried

    return result;
}
